package com.cola.code15;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * @Grup:com.cola.code
 * @Auther:cola
 * @Data:2021/3/22-2021-03-13:39
 * @version:1.0
 */
public class CodeDemo {
    public static void main(String[] args) {
        //通常产生乱码的情况是俩个不兼容的编码相互转换
        //在网络中,客户端与服务端不统一(WEB开发中出现的乱码情况)
        String info ="小河流水哗啦啦!";
        try {
            String newInfo = new String(info.getBytes(StandardCharsets.ISO_8859_1));
            System.out.println(newInfo);
            String newInfo2=new String(newInfo.getBytes(StandardCharsets.ISO_8859_1), Charset.defaultCharset());
            System.out.println(newInfo2);
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
